All Questions
27 questions
6votes
2answers
448views
Family, felon & fuzz River Crossing challenge
I first saw this challenge when a user posted it to SO about two years ago without a shred of code. The post's plea, "How do I get started?" meant the user's post didn't survive long on that ...
2votes
5answers
299views
Sum of bitwise XOR of each subarray weighted by length
here is the problem statement You are given an array a of length n consisting of non-negative integers. You have to calculate the value of \$\sum_{l=1}^n \sum_{r=l}^n f(l,r)\cdot (r - l + 1)\$ where \...
1vote
1answer
365views
Round Robin algorithm implementation
I wrote a program that implements the Round Robin planning algorithm. The total number of processes is read directly from the input standard, and for each process the arrival time and execution time ...
1vote
2answers
363views
Next different permutation in C
This is a program which you can get the next "different", i.e. elements in A[] can be identical, permutation at each call. I've written a C++ program for ...
1vote
1answer
336views
Greedy algorithms to find minimum number of coins (CS50)
I'm taking CS50, an Introduction to CS, and we're asked to do the following task: Suppose that a cashier owes a customer some change and in that cashier’s drawer are quarters (25¢), dimes (10¢), ...
5votes
1answer
264views
Implementing an autocomplete system
Question: Implement an autocomplete system. That is, given a query string s and a set of all possible query strings, return all strings in the set that have s as a prefix. For example, given the query ...
3votes
2answers
266views
LeetCode 665: Non-decreasing Array (C)
I'm posting a solution for LeetCode's "Non-decreasing Array". If you'd like to review, please do. Thank you! Problem Given an array nums with ...
6votes
1answer
651views
LeetCode 1638: Count Substrings That Differ by One Character
I'm posting a solution for LeetCode's "Count Substrings That Differ by One Character". If you'd like to review, please do. Thank you! Problem Given two strings s and t, find the number of ...
9votes
3answers
2kviews
LeetCode 1108: Defanging an IP Address
I'm posting two solutions for LeetCode's "Defanging an IP Address". If you'd like to review, please do. Thank you! Problem Given a valid (IPv4) IP address, return a defanged version of that ...
8votes
2answers
137views
Line wrapping text utility using fixed-size arrays
As an exercise, I've made a text processing utility that wraps arbitrarily long lines of text, but only using fixed-size arrays and other basic C features. I have mostly programmed in Python, C++ and ...
7votes
3answers
1kviews
Cracking the Coding Interview — 1.5 One Away
I would like to know any suggestions about to improve my code solution and your rating of my approach to the problem, I based my code on the fact that if the strings have different length removing one ...
0votes
2answers
534views
Cracking the code interview: Problem 1 .6 basic string compression
I created a GitHub repository containing my code solutions for some of the exercises proposed in the book. I updated my solution for the problem 1.6 here. Description A function that compress the ...
5votes
1answer
5kviews
Code Vita: Chakravyuha
Problem Statement A Chakravyuha is a wheel-like formation. Pictorially it is depicted as below A Chakravyuha has a very well-defined co-ordinate system. Each point on the co-...
4votes
1answer
5kviews
Generate Christmas Tree
Problem Statement: The Christmas tree is comprised of the following Parts Stand Each Part is further comprised of Branches. Branches are comprised of Leaves. How the tree appears as a ...
3votes
3answers
386views
Find k-distinct partitions which contain at least two perfect squares
Problem Statement: A k-distinct-partition of a number \$n\$ is a set of \$k\$ distinct positive integers that add up to \$n\$. For example, the 3-distinct partitions of 10 are \$1+2+7\$ \$1+...